app.controller('usersController' , function($scope, $http, utilService, $location){
	
	$scope.pageArr = [];
	$scope.page = 0;
	$scope.size = 3;
	$scope.totalPage = 0;
	
	$scope.cols = [
		{name: '序号', column: '$index', width: '60px'},
		{name: '用户名', column: 'username'},
		{name: '真实姓名', column: 'realname', width: '100px'},
		{name: '邮箱', column: 'email'},
		{name: '手机号', column: 'mobile', width	: '120px'}
	];
	
	/*
	 *	商品展示
	 * */
	function showUsers(){
		
		utilService.ajax({
			url: '../../api/user_list.php',
			data: {size: $scope.size,query:$scope.selecttxt,page: $scope.page},
			ok: function(response) {
				if (response.success) {
					console.log(response);
					$scope.users = response.data;
					$scope.totalPage = Math.ceil(response.total / $scope.size);
					$scope.pageArr = _.range($scope.totalPage);
				} else {
					// ...
				}
			}
		}, $scope);
	}
	
	$scope.$on("$viewContentLoaded", function(){
		showUsers();
	});
	
	//	分页点击跳转
	$scope.jumpPage = function() {
		$scope.page = this.cpage;
		showUsers();
	};
	
});